
<?php

echo '<br/>';

if ($this->session->flashdata('message'))
    echo "<div class='message'>" . $this->session->flashdata('message') . "</div>";
$iva = $factura['subtotal'] * ($factura['tarifa_iva'] / 100);
$suman = array('id' => 'suman', 'type' => 'text', 'readonly' => 'true', 'name' => 'suman', 'class' => 'form-control', 'size' => '50', 'value' => $factura['suman']);
$num = array('id' => 'numero', 'type' => 'text', 'readonly' => 'true', 'name' => 'numero', 'class' => 'form-control', 'size' => '50', 'value' => $factura['numero']);
$subtotal = array('id' => 'subtotal', 'type' => 'text', 'readonly' => 'true', 'name' => 'subtotal', 'class' => 'form-control', 'size' => '50', 'value' => $factura['subtotal']);
$total = array('id' => 'total', 'type' => 'text', 'readonly' => 'true', 'name' => 'total', 'class' => 'form-control', 'size' => '50', 'value' => $factura['total']);
$tarifaIva = array('id' => 'tarifa', 'type' => 'text', 'readonly' => 'true', 'name' => 'tarifaIva', 'class' => 'form-control', 'size' => '50', 'value' => $iva);

echo validation_errors('<div class="error">', '</div>');
echo '</br>';
echo '</br><div class="panel panel-default">';
echo ' <div class="panel-heading">';
echo '<h3 class="panel-title">Datos de factura</h3>';
echo '</div>';
echo ' <div class="panel-body">';
echo '<div class="row-fluid">';
echo '<div class="col-sm-2">';
echo '<label>Número de Factura</label>';
echo '</div>';
echo '<div class="col-sm-10">';
echo form_input($num);
echo '</div>';
echo '</div>';
echo '</div>';
echo ' </div>';
echo '</br>';

echo '<div class="panel panel-default">';
echo '<div class="panel-heading">Datos de Paciente</div>';
echo '<div class="panel-body">';
echo '<div class="row-fluid">';
echo' <div class="col-lg-2">';
echo '<label>Nombres</label>';
echo '</div>';
echo '<div class="col-lg-10">';
echo $paciente['nombres'] . '';
echo'</div>';
echo '</div>';
echo '<div class="row-fluid">';
echo' <div class="col-lg-2">';
echo '<label>Apellidos</label>';
echo '</div>';
echo '<div class="col-lg-10">';
echo $paciente['apellidos'] . '';
echo'</div>';
echo '</div>';
echo '<div class="row-fluid">';
echo' <div class="col-lg-2">';
echo '<label>Cedula</label>';
echo '</div>';
echo '<div class="col-lg-10">';
echo $paciente['numero_identificacion'] . '';
echo'</div>';
echo '</div>';
echo '</div></div></br>';
echo"<table>";
echo"<tr>";
echo"<td>";
echo '</div>';
echo"</td>";
echo"</tr>";
echo"</table>";

echo'<div class="panel panel-default">';
echo '<div class="panel-heading">Detalles</div>';
echo '<div class="panel-body">';

if ($detalles == null) {
    echo 'No Hay detalles';
} else {
    echo '<table cellpadding="0" name="detalles[]" cellspacing="0" border="1" class="table table-striped table-bordered table-condensed table-responsive" id="detalles" width="100%">';
    echo "<thead>\n<tr>\n";
    echo "<th>Cantidad</th><th>Descripcion</th><th>Total</th>\n";
    foreach ($detalles as $detalle) {
        echo "<tr valign='top'>\n";
        echo "<td id='cantidad' align='left'>" . $detalle['cantidad']. "</td>";
        echo "<td id='descripcion' align='left'>" . $detalle['descripcion'] . "</td>";
        echo "<td align='left'>" . $detalle['total'] . "</td>";
    }
    echo "</tr></tbody>";
    echo "<tr><td></td><td>Suman</td><td>" . form_input($suman) . "</td>\n</tr>";
    echo "<tr><td></td><td>Subtotal</td><td colspan='3'>" . form_input($subtotal) . "</td></tr>";
    echo "<tr><td></td><td>Iva 12</td><td>" . form_input($tarifaIva) . "</td></tr>";
    echo "<tr><td></td><td>Total</td><td>" . form_input($total) . "</td></tr>";
    echo '</table>';
}
echo '</div></div>';

echo '<div class="panel panel-default">';
echo ' <div class="panel-body">';
echo '<div class="input-group">';
echo form_open('facturacion_controller/imprimir', array('id'=>'form', 'target' =>'_blank'));
$btnPrint= array('type' => 'submit', 'class' => 'btn btn-sm btn-primary btn-block', 'value' => 'Imprimir');
echo form_submit($btnPrint);
echo form_close();
echo '</div></div></div></div>';
?>